/**
 * json配置举例，更多配置请看 IConfigSchema
 * @author luguoxiang
 * @date 2022/7/5
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { IConfigSchema, fileSize, LgBizSelect, LgBizSelectProps } from '@/soar';
import { basePath } from './api';
import storageApi, { basePath as storageBasePath } from '../../general/file-storage/api';
import { MenuComponent } from '@/types/interface';
// 获取全部图标的列表

const fieldList: IConfigSchema<any>[] = [
  {
    field: 'originalName',
    label: '文件名称',
    dataType: 'string',
  },
  {
    field: 'storageId',
    label: '所在仓库',
    dataType: 'string',
    table: {
      colKey: 'storageIdName',
    },
    search: {
      component: LgBizSelect,
      componentProps: {
        data: storageApi.query,
      } as LgBizSelectProps,
    },
  },
  {
    field: 'size',
    label: '大小',
    dataType: 'number',
    table: {
      cell(_: any, { row }) {
        return fileSize(row.size);
      },
    },
  },
  {
    field: 'createBy',
    label: '创建人',
    dataType: 'string',
  },
  {
    field: 'createTime',
    label: '创建时间',
    dataType: 'datetime',
  },
];

export default fieldList;

/**
 * 组件配置（用于生成菜单数据）
 */
export const COMPONENTS: MenuComponent[] = [
  {
    title: '文件管理',
    component: () => import('./List.vue'),
    sort: 40,
    keepalive: true,
    icon: 'file',
    permits: [`GET${basePath}/query`, `GET${storageBasePath}/query`],
    elements: [
      // { title: '新增', code: 'create', permits: [`POST${basePath}/create`] },
      // { title: '更新', code: 'update', permits: [`POST${basePath}/update`, `GET${basePath}/detail`] },
      { title: '删除', code: 'remove', permits: [`POST${basePath}/remove`] },
      // { title: '详情', code: 'detail', permits: [`GET${basePath}/detail`] },
      // { title: '导入', code: 'import', permits: [`POST${basePath}/import`] },
      // { title: '导出', code: 'export', permits: [`GET${basePath}/export`] },
      { title: '查看', code: 'view', permits: [] },
    ],
  },
];
